package com.marsproj.bankingmanagesystem.entity;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.Date;

@Data
@NoArgsConstructor
@ApiModel("账户")
public class Flow {

    @ApiModelProperty("主体id")
    private String domid;

    @ApiModelProperty("客体id")
    private String subid;

    @ApiModelProperty("转入or转出")
    private String type;

    @ApiModelProperty("交易额")
    private BigDecimal dealMoney;

    @ApiModelProperty("交易时间")
    private Date dealTime;

    @ApiModelProperty("备注")
    private String remark;

    // 无remark构造器
    public Flow(String domid, String subid, int type, String dealMoney, Date dealTime){
        this(domid,subid,type,dealMoney,dealTime,null);
    }

    public Flow(String domid, String subid, int type, String dealMoney, Date dealTime, String remark) {
        this.domid = domid;
        this.subid = subid;
        this.type = type > 0 ? "转入" : "转出";
        this.dealMoney = new BigDecimal(dealMoney);
        this.dealTime = dealTime;
        this.remark = remark;
    }
}
